package com.chen.controller;

import com.chen.dto.R;
import com.chen.model.UserLoginModel;
import com.chen.service.SysUserLoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: chen
 * @Date: 2021/4/19 10:28 AM
 * @Version 1.0
 */
@RestController
@Api(tags = "用户登录接口相关")
public class UserLoginController {

    @Autowired
    private SysUserLoginService sysUserLoginService;

    @PostMapping("/login")
    @ApiOperation(value = "用户登录接口")
    @ApiImplicitParams(
            {
                    @ApiImplicitParam(name = "username", value = "用户名",
                            dataType = "String", defaultValue = "admin"),
                    @ApiImplicitParam(name = "password", value = "密码",
                            dataType = "String", defaultValue = "123456")
            }
    )
    public R<UserLoginModel> login(@RequestParam("username") String username,
                                   @RequestParam("password") String password) {
        UserLoginModel userLoginModel = sysUserLoginService.
                login(username, password);
        return R.ok(userLoginModel);
    }

}
